﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Dreamer Blog - 后台管理系统</title> 
    <!-- bootstrap 3.0.2 -->
    <link href="/resource/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="/resource/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="/resource/css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="/resource/css/style.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="/resource/js/webuploader-0.1.5/webuploader.css" />
</head>

<body>
<div class="row">
    <div class="col-md-12">
    	<h1 class="panel-heading">系统设置</h1>
        <!--breadcrumbs start -->
        <ul class="breadcrumb">
				<li><a href="/admin/dashboard/toIndex"><i class="fa fa-home"></i> 首页</a></li>
				<li class="active">系统设置</li>
			</ul>
        <!--breadcrumbs end -->
    </div>
</div>
<div class="row">
	<div class="col-lg-12">
		<section class="panel">
		    <div class="panel-body">
		        <form class="col s12" id="form1" th:action="@{/admin/system/update}" th:object="${system}">
		        	<input name="id" type="hidden" th:value="*{id}">
					<input name="logoPath" id="filepath" type="hidden" th:value="*{logoPath}">
		            <div class="form-group form-control-medium">
		                <label for="website">网站地址：</label>
		            	<div class="input-group m-b-10">
	                        <span class="input-group-addon">http://</span>
			                <input id="website" name="website" type="text" class="form-control" th:value="*{website}">
	                    </div>
		            </div>
					<div class="form-group form-control-medium">
						<label for="uploader">网站logo：</label>
						<div id="uploader" class="wu-example">
							<!--用来存放文件信息-->
							<div id="file-priview" class="file-priview">
								<img th:src="${system.website} + ${system.uploaddir} + '/' + *{logoPath}" th:if="*{logoPath} != null and *{logoPath} != ''" />
							</div>
							<div class="btns">
								<div id="picker">选择文件...</div>
							</div>
						</div>
					</div>
		            <div class="form-group form-control-medium">
						<label for="title">站点标题：</label>
		                <input id="title" name="title" type="text" class="form-control" th:value="*{title}">
		            </div>
		            <div class="form-group">
						<label for="keywords">站点关键字：</label>
		                <input id="keywords" name="keywords" type="text" class="form-control" th:value="*{keywords}">
		            </div>
		            <div class="form-group">
						<label for="describe">站点描述：</label>
						<textarea id="describe" name="describe" class="form-control" th:text="*{describe}"></textarea>
		            </div>
		            <div class="form-group form-control-medium">
						<label for="uploaddir">默认上传目录：</label>
						<input id="uploaddir" name="uploaddir" type="text" class="form-control" th:value="*{uploaddir}">
		            </div>
		            <div class="form-group form-control-medium">
						<label for="browseType">站点浏览方式：</label>
						<label class="checkbox-inline">
                            <input type="radio" name="browseType" id="browseType-yes" value="1" th:checked="*{browseType} == 1">动态浏览
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="browseType" id="browseType-no" value="2" th:checked="*{browseType} == 2">静态浏览
                        </label>
		            </div>
		            <div class="form-group form-control-medium">
						<label for="staticdir">默认静态化目录：</label>
						<input id="staticdir" name="staticdir" type="text" class="form-control" th:value="*{staticdir}">
		            </div>
		            <div class="form-group form-control-medium">
						<label for="icp">备案号：</label>
						<input id="icp" name="icp" type="text" class="form-control" th:value="*{icp}">
		            </div>
		            <div class="form-group">
						<label for="copyright">站点版权：</label>
						<input id="copyright" name="copyright" type="text" class="form-control" th:value="*{copyright}">
		            </div>
		            <div class="form-group">
						<label for="appid">畅言AppID：<span style="font-weight:normal;">如还没有畅言，请点击<a href="http://changyan.kuaizhan.com/" target="_blank">畅言官网</a>进行注册。</span></label>
						<input id="appid" name="appid" type="text" class="form-control" th:value="*{appid}">
		            </div>
		            <div class="form-group">
						<label for="appkey">畅言AppKey：</label>
		                <input id="appkey" name="appkey" type="text" class="form-control" th:value="*{appkey}">
		            </div>
		            <div class="form-btn-group-left">
		            	<button type="submit" class="btn btn-info">保存设置</button>
		            </div>
		        </form>
		
		    </div>
		</section>
	</div>
</div>
<script src="/resource/js/jquery.min.js" type="text/javascript"></script>
<!-- Bootstrap -->
<script src="/resource/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="/resource/js/ueditor-1.4.3.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/resource/js/ueditor-1.4.3.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="/resource/js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="/resource/js/jQueryMessage/js/jquery.plugin.message.js"></script>
<script>
	var thumbnailWidth = 178,thumbnailHeight = 178;
	var ueEditor = null;

	$(document).ready(function () {
		//初始化UE编辑器
		ueEditor = UE.getEditor('ue-editor');
		initUploader("picker","file-priview","filepath");
	});

	function initUploader(picker,el,inputEl){
		var uploader = WebUploader.create({
			auto: true,
			// swf文件路径
			swf: '/resource/js/webuploader-0.1.5/Uploader.swf',
			// 文件接收服务端。
			server: '/upload/uploadFile',
			// 选择文件的按钮。可选。
			compress: false,
			// 内部根据当前运行是创建，可能是input元素，也可能是flash.
			pick: '#' + picker,
			fileNumLimit: 5,
			// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
			resize: false,
			duplicate:true
		});
		uploader.on('fileQueued', function(file) {
			$("#"+el).children().remove();
			$img = $("<img />");
			uploader.makeThumb( file, function(error, src) {
				if ( error ) {
					$img.replaceWith('<span>不能预览</span>');
					return;
				}
				$img.attr( 'src', src );
			}, thumbnailWidth, thumbnailHeight );
			$("#"+el).append($img);
		});
		uploader.on('uploadSuccess', function(file, response) {
			console.log(response);
			$("#"+el).children().remove();
			$("#"+el).append($("<img src='"+response.data.url+"'/>"));
			$("#"+inputEl).val(response.data.filepath);
		});
		uploader.on('uploadError', function( file ) {
			$("body").MessageBox({
				type: 'error',
				message: '上传失败！',
				timeout:3000,
				callbak:null
			});
		});
	}

	function validateForm(){
		$("#htmlContent").val(ueEditor.getContent());
		return true;
	}
</script>
</body>
</html>
